package cn.wolfcode.service.impl;

import cn.wolfcode.entity.StrategyRank;
import cn.wolfcode.mapper.StrategyRankMapper;
import cn.wolfcode.service.IStrategyRankService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author c1eye
 * @since 2022-11-03
 */
@Service
public class StrategyRankServiceImpl extends ServiceImpl<StrategyRankMapper, StrategyRank> implements IStrategyRankService {

    @Override
    public List<StrategyRank> queryRank(int type) {
        QueryWrapper<StrategyRank> wrapper = new QueryWrapper<>();
        wrapper.eq("type", type);
        wrapper.inSql("statis_time", "SELECT MAX(statis_time) FROM strategy_rank");
        wrapper.orderByDesc("statisnum");
        wrapper.last("limit 10");
        return list(wrapper);
    }


}
